<template>
  <div id="app">
    <!-- 对话框组件 -->
    <el-button type="text" @click="dialogVisible = true">登录</el-button>
    <el-dialog
      title="登录"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
    >
      <!-- <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span> -->

      <template #default>
        <el-form label-width="80px">
          <el-form-item label="用户名">
            <el-input
              v-model="userForm.username"
              placeholder="请输入用户名"
              prefix-icon="el-icon-user"
            />
          </el-form-item>
          <el-form-item label="密码">
            <el-input
              v-model="userForm.password"
              prefix-icon="el-icon-lock"
              placeholder="请输入密码"
              show-password
            />
          </el-form-item>
        </el-form>
      </template>
      <template #footer>
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      userForm: {
        username: '',
        password: ''
      },
      dialogVisible: false
    }
  },
  methods: {
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => {})
    }
  }
}
</script>

<style lang="less" scoped>
.el-input__inner {
  width: 40% !important;
}
</style>
